home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mgr / sparcmgr / src.zoo / src / port / pixel.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-26  |  1.7 KB  |  68 lines

  1. /*                        Copyright (c) 1989 Bellcore
  2.  *                            All Rights Reserved
  3.  *       Permission is granted to copy or use this program, EXCEPT that it
  4.  *       may not be sold for profit, the copyright notice must be reproduced
  5.  *       on copies, and credit should be given to Bellcore where it is due.
  6.  *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7.  */
  8. /*    $Header: pixel.c,v 1.1 89/05/10 18:21:32 sau Locked $
  9.     $Source: /usr/u/sau/mgr/src/dec/RCS/pixel.c,v $
  10. */
  11. static char    RCSid_[] = "$Source: /usr/u/sau/mgr/src/dec/RCS/pixel.c,v $$Revision: 1.1 $";
  12.  
  13. /*
  14.  * set/clear/ or invert a pixel (Portable version) (SAU) 
  15.  * return current bit setting (i.e. may be used to replace bit_on)
  16.  */
  17.  
  18. #include "bitmap.h"
  19.  
  20. bit_point(map,x,y,op)
  21. register BITMAP *map;
  22. register int x,y;
  23. int op;
  24.    {
  25.    register int bit;                            /* dst bit */
  26.     register DATA *base;                            /* dst word */
  27.  
  28.    /* clipping */
  29.  
  30. #ifndef NOCLIP
  31.    if (x<0 || x>BIT_WIDE(map) || y<0 || y>BIT_HIGH(map))
  32.       return(-1);
  33. #endif
  34.  
  35. #ifdef INVERT
  36.     /* invert all raster ops */
  37.  
  38.     op = op_invert[15&op];
  39. #endif
  40.  
  41.     x += map->x0;
  42.     y += map->y0;
  43.    base = y * BIT_LINE(map) + (x>>LOGBITS) + (map->data);
  44.    bit = GETLSB(MSB,(x & BITS));
  45.   
  46.    switch(OPCODE(op)) {
  47.         case OPCODE(SRC):
  48.         case OPCODE(SRC | DST):
  49.         case OPCODE(SRC | ~DST):
  50.         case OPCODE(~0):
  51.             *base |= bit;
  52.          break;
  53.         case OPCODE(~SRC):
  54.         case OPCODE(~(SRC|DST)):
  55.         case OPCODE(DST & ~SRC):
  56.         case OPCODE(0):
  57.             *base &= ~bit;
  58.          break;
  59.         case OPCODE(SRC ^ DST):
  60.         case OPCODE(~DST):
  61.         case OPCODE(SRC & ~DST):
  62.         case OPCODE(~(SRC&DST)):
  63.             *base ^= bit;
  64.          break;
  65.       }
  66.    return(*base&bit);
  67.    }
  68.